import React, { Component } from 'react'
import axios from "axios"
import "../../style/index"
import Homescss from "./home.module.scss"
 class Home extends Component {
   state={
     arr:[]
   }
  render() {
    let {arr}=this.state
    return (
      <div className={Homescss.homes}>
         {
              arr &&arr.map((item,index)=>{
                  return <dl key={index} onClick={this.homeall.bind(this,item.type)}>
                      <dt>
                        <img src={item.img} alt="" />
                      </dt>
                      <dd>{item.name}</dd>
                  </dl>
              })
         }
      </div>
    )
  }
 async componentDidMount(){
   let res=await axios.get("/api/home")
    if(res.data.code==0){
          this.setState({
             arr:res.data.list
          })
        }
  }
  homeall(type){
      this.props.history.push('/classfil/'+type)
  }

}

export default Home